/*Trie <template>
 *iterate version
 *relic@20070717
 */

#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

const int NUM_CHAR = 26;
const char BC = 'a';

template<typename _Tp>
struct _node {
	_Tp data;
	bool used;
	_node *branch[NUM_CHAR];
	_node() {
		used = false;
		memset(branch, 0, sizeof(branch));
	}
};
template<typename _Tp>
struct trie {
	_node<_Tp> *root;
	trie() {root = new _node<_Tp>;}
	~trie() {
		release(root);
		root = new _node<_Tp>;
	}
	void release(_node<_Tp> *p) {
		for (int i = 0; i < NUM_CHAR; ++ i)
			if (p) release(p->branch[i]);
		delete p;
	}

	void insert(const char *word, _Tp &d) {
		_node<_Tp> *p = root;
		for ( ; *word; ) {
			int index = *word - BC;
			if (p->branch[index] != NULL)
				p = p->branch[index];
			else
				p = p->branch[index] = new _node<_Tp>;
			if (!(*++word)) {
				p->used = true;
				p->data = d;
				return ;
			}
		}
	}
	_node<_Tp> * locate(const char *word) {
		_node<_Tp> *p;
		for (p = root; p && *word; p = p->branch[*word++ - BC]);
		return p;
	}
	bool search(const char *word, _Tp &store) {
		_node<_Tp> *p = locate(word);
		if (p && p->used) {
			store = p->data;
			return true;
		} else {
			return false;
		}
	}
	void erase(const char *word) {
		_node<_Tp> *p = locate(word);
		if (p) p->used = false;
	}

};

int main() {
	char s[32], *p;
	char delim[] = " /";
	trie<string> st;
	while (gets(s)) {
		if (s[0] == '\0') break;
		p = strtok(s, delim);
		string a(p);
		p = strtok(NULL,delim);
		st.insert(p, a);
	}
	while (scanf("%s", s) != EOF) {
		string str;
		if (st.search(s, str))
			printf("%s\n", str.c_str());
		else
			printf("eh\n");
	}
	return 0;
}
